package com.world.web.controller.wifi;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.world.common.annotation.Log;
import com.world.common.core.controller.BaseController;
import com.world.common.core.domain.AjaxResult;
import com.world.common.enums.BusinessType;
import com.world.wifi.domain.WifiNetworkDevice;
import com.world.wifi.service.IWifiNetworkDeviceService;
import com.world.common.utils.poi.ExcelUtil;
import com.world.common.core.page.TableDataInfo;

/**
 * 网络设备Controller
 * 
 * @author LiJunXi
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/wifi/device")
public class WifiNetworkDeviceController extends BaseController
{
    @Autowired
    private IWifiNetworkDeviceService wifiNetworkDeviceService;

    /**
     * 查询网络设备列表
     */
    @PreAuthorize("@ss.hasPermi('wifi:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(WifiNetworkDevice wifiNetworkDevice)
    {
        startPage();
        List<WifiNetworkDevice> list = wifiNetworkDeviceService.selectWifiNetworkDeviceList(wifiNetworkDevice);
        return getDataTable(list);
    }

    /**
     * 导出网络设备列表
     */
    @PreAuthorize("@ss.hasPermi('wifi:device:export')")
    @Log(title = "网络设备", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WifiNetworkDevice wifiNetworkDevice)
    {
        List<WifiNetworkDevice> list = wifiNetworkDeviceService.selectWifiNetworkDeviceList(wifiNetworkDevice);
        ExcelUtil<WifiNetworkDevice> util = new ExcelUtil<WifiNetworkDevice>(WifiNetworkDevice.class);
        util.exportExcel(response, list, "网络设备数据");
    }

    /**
     * 获取网络设备详细信息
     */
    @PreAuthorize("@ss.hasPermi('wifi:device:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return success(wifiNetworkDeviceService.selectWifiNetworkDeviceByDeviceId(deviceId));
    }

    /**
     * 新增网络设备
     */
    @PreAuthorize("@ss.hasPermi('wifi:device:add')")
    @Log(title = "网络设备", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WifiNetworkDevice wifiNetworkDevice)
    {
        return toAjax(wifiNetworkDeviceService.insertWifiNetworkDevice(wifiNetworkDevice));
    }

    /**
     * 修改网络设备
     */
    @PreAuthorize("@ss.hasPermi('wifi:device:edit')")
    @Log(title = "网络设备", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WifiNetworkDevice wifiNetworkDevice)
    {
        return toAjax(wifiNetworkDeviceService.updateWifiNetworkDevice(wifiNetworkDevice));
    }

    /**
     * 删除网络设备
     */
    @PreAuthorize("@ss.hasPermi('wifi:device:remove')")
    @Log(title = "网络设备", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(wifiNetworkDeviceService.deleteWifiNetworkDeviceByDeviceIds(deviceIds));
    }
}
